Merged
Conversation
The existing implementation generates a significant amount of allocations due to concatenating strings. This commit moves it to using a strings.Builder. ``` goos: darwin goarch: arm64 pkg: github.com/Netflix/spectator-go/v2/spectator/meter cpu: Apple M3 Pro BenchmarkToSpectatorId-12 9054499 1323 ns/op 1290 B/op 40 allocs/op BenchmarkToSpectatorIdBuilder-12 18567895 656.0 ns/op 504 B/op 6 allocs/op ```
copperlight
approved these changes
Jul 10, 2025
Collaborator
copperlight
left a comment
There was a problem hiding this comment.
This is very nice change - it is tight, and it directly addresses the string performance issue, without altering the overall design. Thank you for the contribution, and the benchmark demonstrating the performance improvement. 👏🏻
I have another larger change in-flight to add LowLatencyBuffers, which will also help overall processing time when recording metrics in highly concurrent applications.
This change will get tagged with that change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing implementation when creating a
NewIdgenerates a significant amount of allocations due to concatenating strings intoSpectatorId.This commit moves it to using a strings.Builder.